package main

import (
	"bufio"
	"fmt"
	"net"
	"os"
	"time"
)

var (
	welcome  string
	datetime string
)

const (
	AUTHOR string = "venki.chen"
)

func init() {
	now := time.Now()
	datetime = now.Format("2006-01-02 15:04:05")
	welcome = AUTHOR + "欢迎来到今日的golang语言学习，现在的时间是：" + datetime
}

func main() {
	conn, err := net.Dial("tcp", "192.168.5.113:8888")
	if err != nil {
		fmt.Println("conn err=", err)
		return
	}
	fmt.Println("连接成功 suc=", conn)
	reader := bufio.NewReader(os.Stdin)
	line, err01 := reader.ReadString('\n')
	if err01 != nil {
		fmt.Println("reading err=", err01)
	}

	n, err02 := conn.Write([]byte(line))
	if err02 != nil {
		fmt.Println("conn.write err=", err02)
	}

	fmt.Printf("客户端发送了%d字节的数据，并退出", n)

	/*fmt.Println(welcome)
	fmt.Println("--------------------------")
	key.AccessKey()*/
}
